#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int num = 0, count = 0;
    cin >> num >> count;
    vector<long long> dp(num + 1, 0);
    long long sum = 0;
    for (int i = 1; i <= num; i++)
    {
        long long tem = 0;
        cin >> tem;
        sum += tem;
        dp[i] = sum;

    }
    while (count--)
    {
        int left = 0, right = 0;
        cin >> left >> right;
        cout << dp[right] - dp[left - 1] << endl;
    }

    return 0;
}